home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / LOOP.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  131 lines

  1. #ifndef _LINUX_LOOP_H
  2. #define _LINUX_LOOP_H
  3.  
  4. #include <linux/kdev_t.h>
  5.  
  6. /*
  7.  * include/linux/loop.h
  8.  *
  9.  * Written by Theodore Ts'o, 3/29/93.
  10.  *
  11.  * Copyright 1993 by Theodore Ts'o.  Redistribution of this file is
  12.  * permitted under the GNU Public License.
  13.  */
  14.  
  15. #define LO_NAME_SIZE    64
  16. #define LO_KEY_SIZE    32
  17.  
  18. #ifdef __KERNEL__
  19.        
  20. struct loop_device {
  21.     int        lo_number;
  22.     struct dentry    *lo_dentry;
  23.     int        lo_refcnt;
  24.     kdev_t        lo_device;
  25.     int        lo_offset;
  26.     int        lo_encrypt_type;
  27.     int        lo_encrypt_key_size;
  28.     int        lo_flags;
  29.     int        (*transfer)(struct loop_device *, int cmd,
  30.                     char *raw_buf, char *loop_buf, int size,
  31.                     int real_block);
  32.     char        lo_name[LO_NAME_SIZE];
  33.     char        lo_encrypt_key[LO_KEY_SIZE];
  34.     __u32           lo_init[2];
  35.     uid_t        lo_key_owner;    /* Who set the key */
  36.     int        (*ioctl)(struct loop_device *, int cmd, 
  37.                  unsigned long arg); 
  38.  
  39.     struct file *    lo_backing_file;
  40.     void        *key_data; 
  41.     char        key_reserved[48]; /* for use by the filter modules */
  42. };
  43.  
  44. typedef    int (* transfer_proc_t)(struct loop_device *, int cmd,
  45.                 char *raw_buf, char *loop_buf, int size,
  46.                 int real_block);
  47.  
  48. #endif /* __KERNEL__ */
  49.  
  50. /*
  51.  * Loop flags
  52.  */
  53. #define LO_FLAGS_DO_BMAP    0x00000001
  54. #define LO_FLAGS_READ_ONLY    0x00000002
  55.  
  56. /* 
  57.  * Note that this structure gets the wrong offsets when directly used
  58.  * from a glibc program, because glibc has a 32bit dev_t.
  59.  * Prevent people from shooting in their own foot.  
  60.  */
  61. #if __GLIBC__ >= 2 && !defined(dev_t)
  62. #error "Wrong dev_t in loop.h"
  63. #endif 
  64.  
  65. /*
  66.  *    This uses kdev_t because glibc currently has no appropiate
  67.  *    conversion version for the loop ioctls. 
  68.  *     The situation is very unpleasant    
  69.  */
  70.  
  71. struct loop_info {
  72.     int        lo_number;    /* ioctl r/o */
  73.     dev_t        lo_device;     /* ioctl r/o */
  74.     unsigned long    lo_inode;     /* ioctl r/o */
  75.     dev_t        lo_rdevice;     /* ioctl r/o */
  76.     int        lo_offset;
  77.     int        lo_encrypt_type;
  78.     int        lo_encrypt_key_size;     /* ioctl w/o */
  79.     int        lo_flags;    /* ioctl r/o */
  80.     char        lo_name[LO_NAME_SIZE];
  81.     unsigned char    lo_encrypt_key[LO_KEY_SIZE]; /* ioctl w/o */
  82.     unsigned long    lo_init[2];
  83.     char        reserved[4];
  84. };
  85.  
  86. /*
  87.  * Loop filter types
  88.  */
  89.  
  90. #define LO_CRYPT_NONE      0
  91. #define LO_CRYPT_XOR      1
  92. #define LO_CRYPT_DES      2
  93. #define LO_CRYPT_FISH2    3    /* Brand new Twofish encryption */
  94. #define LO_CRYPT_BLOW     4
  95. #define LO_CRYPT_CAST128  5
  96. #define LO_CRYPT_IDEA     6
  97. #define LO_CRYPT_DUMMY    9
  98. #define LO_CRYPT_SKIPJACK 10
  99. #define MAX_LO_CRYPT    20
  100.  
  101. #ifdef __KERNEL__
  102. /* Support for loadable transfer modules */
  103. struct loop_func_table {
  104.     int number;     /* filter type */ 
  105.     int (*transfer)(struct loop_device *lo, int cmd, 
  106.             char *raw_buf, char *loop_buf, int size,
  107.             int real_block);
  108.     int (*init)(struct loop_device *, struct loop_info *); 
  109.     /* release is called from loop_unregister_transfer or clr_fd */
  110.     int (*release)(struct loop_device *); 
  111.     int (*ioctl)(struct loop_device *, int cmd, unsigned long arg);
  112.     /* lock and unlock manage the module use counts */ 
  113.     void (*lock)(struct loop_device *);
  114.     void (*unlock)(struct loop_device *);
  115. }; 
  116.  
  117. int  loop_register_transfer(struct loop_func_table *funcs);
  118. int loop_unregister_transfer(int number); 
  119.  
  120. #endif
  121. /*
  122.  * IOCTL commands --- we will commandeer 0x4C ('L')
  123.  */
  124.  
  125. #define LOOP_SET_FD    0x4C00
  126. #define LOOP_CLR_FD    0x4C01
  127. #define LOOP_SET_STATUS    0x4C02
  128. #define LOOP_GET_STATUS    0x4C03
  129.  
  130. #endif
  131.